﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ivan.Dm.ChromeRemoteDebugger.Transport;

namespace Ivan.Dm.ChromeRemoteDebugger.Protocol {
    public static class MessageFactory {
        public static Message CreateMessage<T>(T command) where T : Command {
            Dictionary<string, string> header = new Dictionary<string, string>();
            header.Add(MessageHeaderParts.ToolEntryKey, command.Tool);
            header.Add(MessageHeaderParts.DestintaionEntryKey, command.Destination);
            string content = JsonHelper.Serialize<T>(command);
            return new Message(header, content);
        } 
    }
}
